home *** CD-ROM | disk | FTP | other *** search
- /*
- shows how to use CreateIP() and CreateTCP()
-
- THIS IS FOR EDUCATIONAL PORPOUSE ONLY!!!
- DON'T ASK WHAT IT IS FOR.
- DON'T EMAIL ME ABOUT IT.
- I DON'T ASSUME ANY RESPONSABILITY ABOUT USING OF IT.
- */
-
- if ~show("L","rexxsupport.library") then
- if ~addlib("rexxsupport.library",0,-30) then do
- say "no rexxsupport.library"
- exit
- end
- if ~show("L","rxsocket.library") then
- if ~addlib("rxsocket.library",0,-30) then do
- say "no rxsocket.library"
- exit
- end
- if ~show("L","rmh.library") then
- if ~addlib("rmh.library",0,-30) then do
- say "no rmh.library"
- exit
- end
-
- prg=ProgramName("NOEXT")
-
- if ~RMH_ReadArgs("FROM/A,TO/A,PORT/A/N") then do
- call PrintFault(IoErr(),prg)
- exit
- end
-
- if parm.2.value<1 | parm.2.value>65535 then do
- say "port '"parm.2.value"' not valid"
- exit
- end
-
- source = resolve(parm.0.value)
- if source==-1 then do
- say "from host '"parm.0.value"' not found"
- exit
- end
-
- dest = resolve(parm.1.value)
- if dest==-1 then do
- say "to host '"parm.1.value"' not found"
- exit
- end
-
- tcp.SPORT = 5000
- tcp.DPORT = parm.2.value
- tcp.SEQ = 1
- tcp.ACK = 0
- tcp.OFF = 5
- tcp.FLAGS = 0
- tcp.WIN = 21
- tcp.URP = 1
- tcp.SRC = source
- tcp.DST = dest
-
-
- SIZEOFIP = 20
- ip.V = 4
- ip.HL = 5
- ip.TOS = 0
- ip.LEN = SIZEOFIP+length(tcpp)
- ip.ID = 100
- ip.OFF = 0
- ip.TTL = 65
- ip.P = 6
- ip.SUM = 0
- ip.SRC = source
- ip.DST = dest
-
- sock = socket("INET","RAW","TCP")
- if sock<0 then do
- say "no socket"
- exit
- end
-
- if setsockopt(sock,"IP","HDRINCL",1)<0 then do
- say "no IP HDRINCL"
- exit
- end
-
- remote.addrfamily = "INET"
- remote.addraddr = dest
-
- do i=0 to 255
- packet = createPacket(i);
- res = sendto(sock,packet,0,"REMOTE")
- if res==-1 then do
- say res Errno()
- exit
- end
- end
- exit
-
- createPacket: PROCEDURE EXPOSE ip. tcp.
- parse arg f
- tcp.FLAGS = f
- ipp = CreateIP("IP")
- tcpp = CreateTCP("TCP")
- return ipp || tcpp
-